#include <iostream>
#include <string>
#include <vector>

using namespace std;

int binary_search(const vector<int>& v, int target)
{
	int l = 0, r = v.size() - 1;
	while(l < r)
	{
		int mid = (l + r) / 2;
		if(target <= v[mid])
			r = mid;
		else
			l = mid + 1;
	}
	return l;
}

int main()
{
	vector<int>v{1,2,3,9,10};
	for(auto& a : v)
		cout << a<< " ";
	cout <<endl;
	cout << "find 3 in idx "<< binary_search(v, 3) << endl;
	cout << "find 7 in idx "<< binary_search(v, 7) << endl;
    return 0;
}
